package com.qixiucoding;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;

public class Main {
    public static void main(String[] args) {
        String inputJson = """
{
  
}
        """;
        String configJson = """
                [
                                
                    {
                        "optype": "getjson",
                        "op": {
                            "#age#": {
                                "expression": "$..age",
                                "datatype": "array"
                            },
                            "#name#": {
                                "expression": "$..name",
                                "datatype": "array"
                            },
                            "#opkey#": {
                                "expression": "$..op",
                                "datatype": "string"
                            }
                        }
                    },
                    {
                        "optype": "createjson",
                        "type": "jsonobject",
                        "op": {
                            "opkey": {
                                "value": "#opkey#",
                                "valuetype": "string"
                            },
                            "names": {
                                "value": "#name#",
                                "valuetype": "array"
                            },
                            "test3": {
                                "value": "#age#",
                                "valuetype": "array"
                            },
                            "test1": {
                                "value": "age1",
                                "valuetype": "string"
                            },
                            "test2": {
                                "value": "age2",
                                "valuetype": "string"
                            },
                            "test": {
                                "value": "age",
                                "valuetype": "string"
                            }
                        }
                    },
                    {
                        "optype": "resultjson",
                "template": "{\\"hey1\\":{test1},\\"hey2\\":{test2},\\"hey3\\":{test3}}",
                        "keys": [
                            "test1",
                            "test2",
                            "test3"
                        ]
                    }
                ]         
                """;

        JsonProcessor processor = new JsonProcessor();
        String result = processor.process(inputJson, configJson);
        System.out.println(result);
//        System.out.println(JSON.toJSONString(null));
//        System.out.println(StrUtil.replace("aaba", "ab", null));
    }
}